RemoveDuplicates Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Remove consecutive equal items from a collection, yielding another collection. In each run of consecutive equal items in the collection, all items after the first item in the run are removed. A passed IEqualityComparer is used to determine equality.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static IEnumerable<T> RemoveDuplicates<T>(
	IEnumerable<T> collection,
	IEqualityComparer<T> equalityComparer
)
Visual Basic (Declaration)
Public Shared Function RemoveDuplicates(Of T) ( _
	collection As IEnumerable(Of T), _
	equalityComparer As IEqualityComparer(Of T) _
) As IEnumerable(Of T)
Visual C++
public:
generic<typename T>
static IEnumerable<T>^ RemoveDuplicates (
	IEnumerable<T>^ collection, 
	IEqualityComparer<T>^ equalityComparer
)

Parameters

collection
IEnumerable<(Of <T>)>
The collection to process.
equalityComparer
IEqualityComparer<(Of <T>)>
The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called.

Return Value

An new collection with the items from collection, in the same order, with consecutive duplicates removed.

Type Parameters

T

Exceptions

ExceptionCondition
System..::ArgumentNullExceptioncollection or equalityComparer is null.

See Also